{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Plot Marmousi Snapshots**\n",
    "\n",
    "**Daniel Köhn**\n",
    "\n",
    "**Kiel, 24/06/2016**\n",
    "\n",
    "**Import necessary packages**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from __future__ import division\n",
    "import matplotlib.pyplot as plt\n",
    "import matplotlib as mpl\n",
    "import numpy as np\n",
    "from matplotlib.colors import LightSource, Normalize\n",
    "from matplotlib.pyplot import gca\n",
    "from pylab import rcParams\n",
    "from matplotlib import rc\n",
    "import scipy.ndimage.filters\n",
    "import pickle"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**FD grid dimensions **"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "DH = 4.0;\n",
    "NX = 6250;\n",
    "NY = 200;\n",
    "N = NX * NY;"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Wavefield snapshot parameters**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "clip = 1e-8        # wavefield clipping\n",
    "NSNAP1 = 1         # first snapshot\n",
    "NSNAP2 = 50        # last snapshot\n",
    "DSNAP = 1          # snapshot increment\n",
    "TSNAP1 = 0.002     # time of first snapshot\n",
    "TSNAP2 = 4.0       # time of last snapshot\n",
    "TSNAPINC = 0.08    # time increment between snapshots"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Define fonts**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "FSize = 25\n",
    "font = {'color':  'black',\n",
    "        'weight': 'bold',\n",
    "        'size': FSize}\n",
    "mpl.rc('xtick', labelsize=FSize) \n",
    "mpl.rc('ytick', labelsize=FSize) \n",
    "rcParams['figure.figsize'] = 12, 5"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Read S-wave velocity model and RTM result**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "f = open ('skagerrak_shot_1.p')\n",
    "data_type = np.dtype ('float32').newbyteorder ('<')\n",
    "snap = np.fromfile (f, dtype=data_type)\n",
    "snap = snap.reshape(NX,NY)\n",
    "snap = np.transpose(snap)\n",
    "snap = np.flipud(snap)\n",
    "f.close()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Define Axis**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "x = np.arange(0.0, DH*NX/1000.0, DH)\n",
    "y = np.arange(0.0, DH*NY/1000.0, DH)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Plot $\\alpha$-Blending of Vp model (Gray) and snapshots (Seismic)**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "extent = [0.0,NX*DH/1000.0,0.0,NY*DH/1000.0]\n",
    "\n",
    "fig = plt.figure(frameon=True)\n",
    "\n",
    "plt.rc('font',**{'family':'sans-serif','sans-serif':['Helvetica']})\n",
    "plt.rc('text', usetex=True)\n",
    "\n",
    "im2 = plt.imshow(snap, cmap=plt.cm.seismic, interpolation='bicubic',\n",
    "                 extent=extent, vmin=-clip, vmax=clip, aspect='auto')\n",
    "\n",
    "a = gca()\n",
    "a.set_xticklabels(a.get_xticks(), font)\n",
    "a.set_yticklabels(a.get_yticks(), font)\n",
    "#plt.axis('scaled')\n",
    "name_title = \"10 Hz monochromatic pressure wavefield\"\n",
    "plt.title(name_title, fontdict=font)\n",
    "plt.ylabel('Depth [km]', fontdict=font)\n",
    "plt.xlabel('Distance [km]', fontdict=font)\n",
    "plt.gca().invert_yaxis()\n",
    "    # add annotation\n",
    "    # plt.text(0.2,3.15,'Computation time: 2.1 s',fontdict=font,color='black',size=30)\n",
    "#cbar=plt.colorbar()\n",
    "#cbar.set_label('t[s]', fontdict=font, labelpad=1)\n",
    "plt.tight_layout()\n",
    "    #plt.savefig('Marmousi_RTM.pdf', format='pdf')\n",
    "name_snap = \"pics/GERMAINE_snap_shot_1.pdf\"\n",
    "plt.savefig(name_snap, bbox_inches='tight', format='pdf')\n",
    "plt.hold(False)\n",
    "#plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python [default]",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
